﻿@model IEnumerable<LAVAA.DAL.Activity>
@{
    ViewBag.Title = "ListActivities";
}

@{
    var grid = new WebGrid(Model, rowsPerPage: 4);
}

<h2>ListActivities</h2>

<h3>@Html.ActionLink("Ny aktivitet", "CreateActivity", "UseCase01")</h3>

@grid.GetHtml(
    rowStyle: "webgrid-row",
    alternatingRowStyle: "webgrid-row-alternating",
    columns: grid.Columns(
        grid.Column(format: @<input type="hidden" class="hiddenId" value="@item.Id"/>),
        grid.Column("Date", "Datum", format: item => item.Date.ToString("yyyy-MM-dd")),
        grid.Column("ActivityType.Name", "Typ"),
        grid.Column("Comment", "Kommentar", style: "webgrid-column"),
        grid.Column("DurationInMinutes", "Varaktighet (min)")
    ))

<script type="text/javascript">
    $(function(){
        $('tbody tr').live('hover', function(){
            $(this).toggleClass('webgrid-clickable');
        }).live('click', function(){
            location.href = '/UseCase01/EditActivity/' + $(this).find(".hiddenId").val();
        }); 
    });
</script>